
package ch.hearc.coursJava.kitBase.set;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;



public class UseSet
	{
	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/

	public static void main(String[] args)
		{
		main();
		}

	public static void main()
		{
		useHashSet();
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/

	private static void useHashSet()
		{
		Set<Integer> setAge = new HashSet<Integer>();

		fill(setAge);
		afficherForeach(setAge);
		afficherIterator(setAge);
		afficher(setAge);
		}

	private static void afficher(Set<Integer> setAge)
		{
		System.out.println("Afficher toString");
		System.out.println(setAge);
		}

	private static void afficherIterator(Set<Integer> setAge)
		{
		System.out.println("Afficher iterator");

		Iterator<Integer> it = setAge.iterator();
		while(it.hasNext())
			{
			Integer elem = it.next();
			System.out.println(elem);
			}
		}

	private static void afficherForeach(Set<Integer> setAge)
		{
		System.out.println("Afficher foreach");

		for(Integer elem : setAge)
			{
			System.out.println(elem);
			}
		}

	private static void fill(Set<Integer> setAge)
		{
		setAge.add(1);
		setAge.add(2);
		setAge.add(1); //Pas ajouter car deja contenu
		}
	}

